import 'package:backend.core/core/domain/entities/access_token_claim.dart';
import 'package:backend.core/core/domain/errors/failures.dart';
import 'package:backend.core/core/domain/services/access_token_service/service.dart';
import 'package:dartz/dartz.dart';

abstract class VerifyAccessToken {
  Either<AccessTokenVerificationFailure, AccessTokenClaim> call({
    required String accessTokenData,
  });
}

class VerifyAccessTokenImpl implements VerifyAccessToken {
  const VerifyAccessTokenImpl({
    required AccessTokenService accessTokenService,
  }) : _accessTokenService = accessTokenService;

  final AccessTokenService _accessTokenService;

  @override
  Either<AccessTokenVerificationFailure, AccessTokenClaim> call({
    required String accessTokenData,
  }) {
    return _accessTokenService.verify(
      accessTokenValue: accessTokenData,
    );
  }
}
